/**
 * Copyright 2013 Mr.Hai Mobile Developer. All rights reserved.
 * HAI PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.hector.meinewerk.lib.network.http;

import java.io.IOException;

/**
 * 
 * request multipart (interface)
 * 
 * @author: HaiTC3
 * @version: 1.1
 * @since: 1.0 | Mar 8, 2013
 */
public class HTTPMultiPartRequest extends HTTPRequest {
	MultiPartInputStream multiPartStream;

	public void setMultipartStream(MultiPartInputStream stream) {
		this.multiPartStream = stream;
	}

	@Override
	public void getNextPart(Data data) {
		// TODO Auto-generated method stub
		try {
			// if (data.buffer == null) {
			// data.buffer = new byte[1024];
			// }
			// data.length = multiPartStream.read(data.buffer, 0,
			// data.buffer.length);
			data.buffer = new byte[multiPartStream.data.length];
			multiPartStream.readFull(data.buffer);
			data.isFinish = (data.length != -1);
			if (data.isFinish) {
				multiPartStream.close();
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
